<template>
    <ul class="main-list">
      <li v-for="item in data" :key="item.dataId">
        <router-link :to="geneDetailRoute(item.dataId)" class="fl picture">
          <img
            :src="item.img_url"
            :alt="item.name"
            :title="item.name"
          />
        </router-link>
        <div class="item-detail">
          <h3 :title="item.name" class="ellipsis-2">
            <router-link :to="geneDetailRoute(item.dataId)">{{item.name}}</router-link>
          </h3>
          <div class="item-info">
            <span>{{item.author || ''}}</span>
            <span>发布时间 {{item.publishTime | fomatDate}}</span>
          </div>
        </div>
      </li>
    </ul>
</template>

<script>
  import {fieldState, geneDetailRoute} from "@/mixins"

  import dateFormater from '@/assets/js/basic/dateFormatUtil'

  export default {
    name: "MainList",
    mixins: [fieldState, geneDetailRoute],
    props: {
      data: Array
    },
    filters: {
      fomatDate (time, fomat = 'yyyy-MM-dd') {
        let date = new Date(time);
        if (date.getTime() !== time) {
          return '';
        }
        return dateFormater.format(date, fomat);
      }
    }
  }
</script>

<style scoped>
  li:first-child {
    border-top: none;
  }
  li {
    padding: 20px 0;
    border-top: 1px solid #e6e6e6;
    overflow: hidden;
    position: relative;
  }
  li:hover {
    background-color: #fdf9f5;
  }
  .picture {
    margin-right: 20px;
    width: 230px;
    height: 130px;
    overflow: hidden;
    min-width: 230px;
    max-width: 230px;
    display: block;
    position: relative;
  }
  li img {
    width: 100%;
    min-height: 130px;
  }
  h3{
    font-size: 20px;
    font-weight: 400;
  }
  h3 a:hover{
    color: #f29838;
  }
  .item-info {
    position: absolute;
    left: 250px;
    bottom: 25px;
  }
  .item-info span {
    isplay: inline-block;
    color: #cbcbcb;
    font-size: 14px;
    margin-right: 10px;
  }
</style>
